package com.bawei.module_detail.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.bawei.module_detail.ui.CommentFragment
import com.bawei.module_detail.ui.RecommendFragment


class MyFragmentAdapter(
    fragmentActivity: FragmentActivity,
    private val pauseVideo: () -> Unit,
    private val playVideo: () -> Unit,
    private val item_id : String,
    private val video_item : String,
) : FragmentStateAdapter(fragmentActivity) {
    override fun getItemCount(): Int {
        return 2
    }

    override fun createFragment(position: Int): Fragment {
        return  when(position){
            0 -> RecommendFragment(
                pauseVideo,
                playVideo,
                video_item
//                title,
//                time,
//                avatar_url,
//                user_id,
//                item_id
            )
            1 -> CommentFragment(
                pauseVideo,
                playVideo,
                item_id
            )
            else -> RecommendFragment(
                pauseVideo, playVideo, video_item
               // title, time, avatar_url, user_id,item_id,
            )
        }
    }

}